package com.song.view.gis;

import java.util.ArrayList;

public class Cluster implements java.io.Serializable {

	private static final long serialVersionUID = -2680147087061210139L;
	private ArrayList features = new ArrayList<Feature>();
	private Double minx;
	private Double maxx;
	private Double miny;
	private Double maxy;

	public void push(Feature f) {
		if (f != null) {
			if (this.features.size() == 0) {
				minx = f.getJd();
				maxx = f.getJd();
				miny = f.getWd();
				maxy = f.getWd();
			} else {

				if (minx > f.getJd())
					minx = f.getJd();
				if (maxx < f.getJd())
					maxx = f.getJd();

				if (miny > f.getWd())
					miny = f.getWd();
				if (maxy < f.getWd())
					maxy = f.getWd();
			}
			this.features.add(f);
		}
	}

	public Double getCenterLon() {
		Double clon;
		clon = minx + (maxx - minx) / 2;
		return clon;
	}

	public Double getCenterLat() {
		Double clat;
		clat = miny + (maxy - miny) / 2;
		return clat;
	}

	public Integer getSize() {
		return this.features.size();
	}

	public ArrayList getFeatures() {
		return features;
	}

}
